import { createRouter, createWebHashHistory } from 'vue-router'
import NotFound from '@/views/NotFound.vue'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    { path: '/', redirect: './profile', meta: { title: '个人信息' } },
    {
      path: '/profile',
      component: () => import('../views/ProfileEdit.vue'),
      meta: { title: '个人信息' },
    },
    {
      path: '/nickname',
      component: () => import('../views/NickName.vue'),
      meta: { title: '编辑昵称' },
    },
    {
      path: '/userinfo',
      component: () => import('../views/UserInfoEdit.vue'),
      meta: { title: '编辑简介' },
    },
    { path: '/:pathMatch(.*)*', component: NotFound },
  ],
})

router.afterEach((to) => {
  document.title = to.meta.title as string
})

export default router
